 class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
     TreeNode() {}
      TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
public class bibtwork1 {
    public boolean isSymmetric(TreeNode root) {
    //101. 对称二叉树
        if(root==null){
            return true;
        }
        return newTreeis(root.left,root.right);
    }
    public boolean newTreeis(TreeNode nleft,TreeNode nright){
        if(nleft==null&&nright==null){
            return true;
        }
        if((nleft!=null&&nright==null)||(nleft==null&&nright!=null)){
            return false;
        }
        if(nleft.val!=nright.val){
            return false;
        }
        return newTreeis(nleft.left,nright.right)&&newTreeis(nleft.right,nright.left);

    }
}
